<template>
    <div class="wy-main business-car-manage">
     <a-row class="wy-main-title">
       <a-col :span="24">
				<p class="title-p">
					<a-divider class="title-vertical"  type="vertical" />
					<span class="title-span" >个人基本资料审核</span>
					<a-divider class="title-divider"  />
				</p>
			</a-col>
	   </a-row>
     <div class="my-main-cont">
         <a-input v-model="nickName" placeholder="请输入姓名" style="width: 200px"/>
         <a-button type="primary" style="margin-left: 10px;"  @click="getSupplyInfo">查询</a-button>
			   <a-button style="margin-left: 10px;" @click="reset">重置</a-button>
				 <a-button class="title-button" type="primary" style="float: right" @click="seeAllInfo()">批量审核</a-button>
         <a-table :columns="columns" @change="handleTableChange" :rowKey="record=> record.username" :dataSource="data"  :pagination="pagination" :loading="loading"  :rowSelection="{selectedRowKeys: selectedRowKeys,onChange:onSelectChange }" style="margin-top: 20px " >
					 <!-- :rowSelection="rowSelection" -->
         <span slot="fromCity" slot-scope="text, record">
				{{record.fromCity}}-{{record.toCity}}
			   </span>
				 <span slot="approvalStatus" slot-scope="text, record">
	   						<a v-if="record.approvalStatus==106" class="wei_warning" href="javascript:;" @click="edit(record)">待审核</a>
						    <a v-if="record.approvalStatus==107" class="wei_primary" href="javascript:;" @click="edit(record)">审核通过</a>
                <a v-if="record.approvalStatus==108" class="wei_danger" href="javascript:;" @click="edit(record)">审核失败</a>
		     </span>
         <span slot="createTime" slot-scope="text, record">
                <span v-if="!!record.createTime">{{record.createTime.split(" ")[0]}}</span>

              </span>
				 </a-table>
<!--           <div style="margin-top: -50px" >
            <a-button @click="delVehicles">删除所选</a-button>
          </div>  -->
					<a-modal title="个人基本资料审核" :visible="visible" @cancel="handleCancel" width="1000px" :maskClosable='false' :footer="null"  >
			     <PublishForm v-if="visible"  :type="type" :detail="detail" @cancel="handleCancel"></PublishForm>
	      	</a-modal>
	      <a-modal title="个人基本资料审核" :visible="visibleAll"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
           <Perdata-add-all v-if="visibleAll" @cancel="handleCancel" :datailAll='datailAll'></Perdata-add-all>
        </a-modal>
     </div>
    </div>
</template>
<script>
import PublishForm from './PublishForm'
import PerdataAddAll from './PerdataAddAll'
	const columns = [{
			title: '真实姓名',
			dataIndex: 'nickName',
      key: 'nickName'
		},
		{
			title: '所属行业',
			dataIndex: 'tradeValue',
		  key:'tradeValue'
		},
		{
			title: '手机号码',
			dataIndex: 'mobile',
      key:'mobile'
		},
		{
			title: '电子邮箱',
			dataIndex: 'email',
      key:'email'
		},
		{
			title: '提交日期',
			dataIndex: 'createTime',
      key:'createTime',
			scopedSlots: {
				customRender: 'createTime'
			},
		},
		{
			title: '操作',
			key: 'approvalStatus',
			scopedSlots: {
				customRender: 'approvalStatus'
			},
		}
	];


// const rowSelection = {
//   onChange: (selectedRowKeys, selectedRows) => {
// 		console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
// 		// this.selectedRowKeys = selectedRowKeys
// 		// console.log(selectedRowKeys)
//   }
// }
export default {
    data() {
        return {
				 type: '',// 操作类型
         nickName:'',
				 detail: {},
				 data:[],
				 columns,
				 loading: false,
				 visible:false,
				 visibleAll:false,
        pagination: {
          pageSizeOptions: ['10', '20', '30', '40', '100'],
          defaultCurrent: 1,
          defaultPageSize: 10,
          total:10,
          showSizeChanger: true,
          showTotal: (total, range) => `共 ${total} 条记录`
        },
					selectedRowKeys: [],
        }
		},
		mounted:function () {
			
		},
		components: {
			PublishForm,
			PerdataAddAll
		},
		created() {
			this.getSupplyInfo()
		},
    methods: {

			handleCancel(e) {
				this.visible = false
			this.visibleAll = false
      this.getSupplyInfo();
      this.selectedRowKeys=[];
			},

			 seeAllInfo(){
        if(this.selectedRowKeys.length){
            this.visibleAll = true;
            let logIds = [];
           for(var i=0;i<this.selectedRowKeys.length;i++){
            logIds.push({"username":this.selectedRowKeys[i]})
           }
            this.datailAll = logIds;
          }else{
            this.$message.success('请选择待审核人!')
          }
      
      },
			// 取消按钮
			// cancleShowModal() {
			// 	this.visible = false
			// },
				// 编辑货物信息
			edit(data){
				this.type = 'edit'
				this.detail = data
				this.visible = true
			},
			//删除
			 delVehicles() {
        this.$confirm({
					title: '确定删除所选中的记录？',
					content: '当您点击确定按钮后，这些记录将会被彻底删除',
					centered: true
				})
      },

			// 重置
			reset () {
				this.pagination.defaultCurrent = 1;
				this.nickName = '';
				this.getSupplyInfo();
			},
				// 获取货源信息
			getSupplyInfo(params = {}) {
				this.loading = true
				this.$get('/user/', {
					pageSize: this.pagination.defaultPageSize,
					pageNum: this.pagination.defaultCurrent,
					type: 1//1个人，2企业
				}).then((r) => {
						console.log(r)
						this.loading = false
						this.data = r.data.rows
						this.pagination.total = r.data.total
					})
					.catch((e) => {
						console.log(e)
						this.loading = false;
					})
			},
			               // 表格排序 分页 筛选事件
      handleTableChange(pagination, filters, sorter) {
         this.pagination.defaultPageSize = pagination.pageSize
         this.pagination.defaultCurrent  = pagination.current
         this.getSupplyInfo();
        // this.getcarSource({
        //   ...this.queryParams
        // })
      },
 			onSelectChange (selectedRowKeys) {
          console.log('selectedRowKeys changed: ', selectedRowKeys);
          this.selectedRowKeys = selectedRowKeys
        },

    }
}
</script>

<style lang="less">

</style>